import 'package:covid_19/constants.dart';
import 'package:covid_19/widgets/line_chart.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class InfoCard extends StatelessWidget {
  final String title;
  final int effectedNum;
  final Color iconColor;
  final Function press;
  const InfoCard({
    Key key,
    this.title,
    this.effectedNum,
    this.iconColor,
    this.press,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(builder: (context, constraints) {
      return GestureDetector(
        onTap: press,
        child: Container(
          width: constraints.maxWidth / 2 - 10,
          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(10.0),
                child: Row(
                  children: [
                    Container(
                      alignment: Alignment.center,
                      height: 30,
                      width: 30,
                      child: SvgPicture.asset(
                        'assets/icons/running.svg',
                        width: 12,
                        height: 12,
                        color: iconColor,
                      ),
                      decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          color: iconColor.withOpacity(.12)),
                    ),
                    SizedBox(width: 5),
                    Text(
                      title,
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                    )
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(bottom: 10),
                child: Row(
                  children: [
                    Padding(
                      padding: const EdgeInsets.all(10.0),
                      child: RichText(
                        text: TextSpan(
                            style: TextStyle(color: kTextColor),
                            children: [
                              TextSpan(
                                  text: '$effectedNum \n',
                                  style: Theme.of(context)
                                      .textTheme
                                      .title
                                      .copyWith(fontWeight: FontWeight.bold)),
                              TextSpan(
                                  text: 'people',
                                  style: TextStyle(fontSize: 12, height: 2))
                            ]),
                      ),
                    ),
                    Expanded(
                      child: LineReportChart(),
                    )
                  ],
                ),
              )
            ],
          ),
          decoration: BoxDecoration(
              color: Colors.white, borderRadius: BorderRadius.circular(8)),
        ),
      );
    });
  }
}
